package com.gton.controller;

import com.gton.common.Resp;
import com.gton.config.MyConfigReadPolaris;
import com.gton.config.ReadPolarisNaocsConfig;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.HashMap;
import java.util.Map;
import java.util.logging.Logger;

/**
 * @description: 测试
 * @author: GuoTong
 * @createTime: 2022-11-12 16:55
 * @since JDK 1.8 OR 11
 **/
@RestController
@RequestMapping("/test2")
public class Test2Controller {

    private static final Logger logger = Logger.getLogger(Test2Controller.class.getSimpleName());
    /**
     * Description: 配置中心中的配置信息映射的配置类
     *
     * @author: GuoTong
     */
    @Autowired
    private MyConfigReadPolaris myConfigReadPolaris;


    @Autowired
    private ReadPolarisNaocsConfig readPolarisNaocsConfig;

    @GetMapping("/list")
    public Resp hello() {
        Map<String, Object> data = new HashMap<>();
        data.put("call-UrI", "hello");
        data.put("port", "8089");
        data.put("service-Name", "cloud-nacos");
        data.put("server-type", "nacos");
        data.put("server-addr", "120.53.238.87:8848");
        data.put("swagger-Uri", "doc.html");
        return Resp.Ok(data);
    }


    @GetMapping("/getConfigByPolaris")
    public Resp getConfigByPolaris() {
        logger.info(myConfigReadPolaris.getName());
        return Resp.Ok(myConfigReadPolaris);
    }

    @GetMapping("/getNacosConfig")
    public Resp getNacosConfig() {
        logger.info(readPolarisNaocsConfig.getConfig().toString());
        return Resp.Ok(readPolarisNaocsConfig);
    }
}
